package solved;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

/*
 ID:	liluyan1
 LANG:	JAVA
 TASK:	ariprog
 */
public class ariprog {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("ariprog.in"));
		ArrayList<Solution> res = new ariprog().solve(f);
		
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"ariprog.out")));
		Collections.sort(res, new Comparator<Solution>(){
			public int compare(Solution a, Solution b) {
				return a.d - b.d;
			}
		});
		for (Solution s : res) {
			out.println(s.a0 + " " + s.d);
		}
		if (res.size() == 0) out.println("NONE");
		
		out.close();
		System.exit(0);
	}
	
	public int read(BufferedReader f) throws IOException {
		return Integer.parseInt(f.readLine());
	}
	
	private ArrayList<Solution> solve(BufferedReader f) throws IOException {
		int N = read(f);
		int M = read(f);
		
		ArrayList<Solution> res = new ArrayList<Solution>();
		
		ArrayList<Integer> list = new ArrayList<Integer>();
		int MAX = 2*M*M;
		boolean[] map = new boolean[MAX+1];
		
		for (int p=0; p<=M; p++) {
			for (int q=0; q<=M; q++) {
				map[p*p + q*q] = true;
			}
		}
		
		for (int i=0; i<=MAX; i++) if (map[i]) list.add(i);
		
		for (int i=0; i<=list.size()-N; i++) {
			int a0 = list.get(i);
			for (int j=i+1; j<=list.size()-N+1; j++) {
				int a1 = list.get(j);
				int d = a1 - a0;
				boolean found = true;
				for (int k=2; k<N; k++) {
					if (a0+k*d>MAX || !map[a0 + k*d]) {
						found = false;
						break;
					}
				}
				if (found) {
					res.add(new Solution(a0, d));
				}
			}
		}
		
		return res;
	}
	
	private class Solution {
		int a0, d;
		public Solution(int a0, int d) {
			this.a0 = a0;
			this.d = d;
		}
	}
}
